package com.grpc;

import hello.HelloProto;
import hello.HelloRequest;
import hello.HelloResponse;
import hello.HelloResponseList;

import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.*;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.*;

/**
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.8.0)",
    comments = "Source: hello.proto")
public final class HelloGrpc {

  private HelloGrpc() {}

  public static final String SERVICE_NAME = "hello.Hello";

  // Static method descriptors that strictly reflect the proto.
  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  @Deprecated // Use {@link #getSayHelloMethod()} instead.
  public static final io.grpc.MethodDescriptor<HelloRequest,
          HelloResponse> METHOD_SAY_HELLO = getSayHelloMethod();

  private static volatile io.grpc.MethodDescriptor<HelloRequest,
      HelloResponse> getSayHelloMethod;

  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  public static io.grpc.MethodDescriptor<HelloRequest,
      HelloResponse> getSayHelloMethod() {
    io.grpc.MethodDescriptor<HelloRequest, HelloResponse> getSayHelloMethod;
    if ((getSayHelloMethod = HelloGrpc.getSayHelloMethod) == null) {
      synchronized (HelloGrpc.class) {
        if ((getSayHelloMethod = HelloGrpc.getSayHelloMethod) == null) {
          HelloGrpc.getSayHelloMethod = getSayHelloMethod = 
              io.grpc.MethodDescriptor.<HelloRequest, HelloResponse>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
              .setFullMethodName(generateFullMethodName(
                  "hello.Hello", "SayHello"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  HelloRequest.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  HelloResponse.getDefaultInstance()))
                  .setSchemaDescriptor(new HelloMethodDescriptorSupplier("SayHello"))
                  .build();
          }
        }
     }
     return getSayHelloMethod;
  }
  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  @Deprecated // Use {@link #getServiceStreamHelloMethod()} instead.
  public static final io.grpc.MethodDescriptor<HelloRequest,
      HelloResponse> METHOD_SERVICE_STREAM_HELLO = getServiceStreamHelloMethod();

  private static volatile io.grpc.MethodDescriptor<HelloRequest,
      HelloResponse> getServiceStreamHelloMethod;

  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  public static io.grpc.MethodDescriptor<HelloRequest,
      HelloResponse> getServiceStreamHelloMethod() {
    io.grpc.MethodDescriptor<HelloRequest, HelloResponse> getServiceStreamHelloMethod;
    if ((getServiceStreamHelloMethod = HelloGrpc.getServiceStreamHelloMethod) == null) {
      synchronized (HelloGrpc.class) {
        if ((getServiceStreamHelloMethod = HelloGrpc.getServiceStreamHelloMethod) == null) {
          HelloGrpc.getServiceStreamHelloMethod = getServiceStreamHelloMethod = 
              io.grpc.MethodDescriptor.<HelloRequest, HelloResponse>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
              .setFullMethodName(generateFullMethodName(
                  "hello.Hello", "serviceStreamHello"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  HelloRequest.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  HelloResponse.getDefaultInstance()))
                  .setSchemaDescriptor(new HelloMethodDescriptorSupplier("serviceStreamHello"))
                  .build();
          }
        }
     }
     return getServiceStreamHelloMethod;
  }
  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  @Deprecated // Use {@link #getClientStreamHelloMethod()} instead.
  public static final io.grpc.MethodDescriptor<HelloRequest,
          HelloResponseList> METHOD_CLIENT_STREAM_HELLO = getClientStreamHelloMethod();

  private static volatile io.grpc.MethodDescriptor<HelloRequest,
      HelloResponseList> getClientStreamHelloMethod;

  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  public static io.grpc.MethodDescriptor<HelloRequest,
      HelloResponseList> getClientStreamHelloMethod() {
    io.grpc.MethodDescriptor<HelloRequest, HelloResponseList> getClientStreamHelloMethod;
    if ((getClientStreamHelloMethod = HelloGrpc.getClientStreamHelloMethod) == null) {
      synchronized (HelloGrpc.class) {
        if ((getClientStreamHelloMethod = HelloGrpc.getClientStreamHelloMethod) == null) {
          HelloGrpc.getClientStreamHelloMethod = getClientStreamHelloMethod = 
              io.grpc.MethodDescriptor.<HelloRequest, HelloResponseList>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING)
              .setFullMethodName(generateFullMethodName(
                  "hello.Hello", "clientStreamHello"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  HelloRequest.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  HelloResponseList.getDefaultInstance()))
                  .setSchemaDescriptor(new HelloMethodDescriptorSupplier("clientStreamHello"))
                  .build();
          }
        }
     }
     return getClientStreamHelloMethod;
  }
  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  @Deprecated // Use {@link #getClientServiceStreamHelloMethod()} instead.
  public static final io.grpc.MethodDescriptor<HelloRequest,
      HelloResponse> METHOD_CLIENT_SERVICE_STREAM_HELLO = getClientServiceStreamHelloMethod();

  private static volatile io.grpc.MethodDescriptor<HelloRequest,
      HelloResponse> getClientServiceStreamHelloMethod;

  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  public static io.grpc.MethodDescriptor<HelloRequest,
      HelloResponse> getClientServiceStreamHelloMethod() {
    io.grpc.MethodDescriptor<HelloRequest, HelloResponse> getClientServiceStreamHelloMethod;
    if ((getClientServiceStreamHelloMethod = HelloGrpc.getClientServiceStreamHelloMethod) == null) {
      synchronized (HelloGrpc.class) {
        if ((getClientServiceStreamHelloMethod = HelloGrpc.getClientServiceStreamHelloMethod) == null) {
          HelloGrpc.getClientServiceStreamHelloMethod = getClientServiceStreamHelloMethod = 
              io.grpc.MethodDescriptor.<HelloRequest, HelloResponse>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
              .setFullMethodName(generateFullMethodName(
                  "hello.Hello", "clientServiceStreamHello"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  HelloRequest.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  HelloResponse.getDefaultInstance()))
                  .setSchemaDescriptor(new HelloMethodDescriptorSupplier("clientServiceStreamHello"))
                  .build();
          }
        }
     }
     return getClientServiceStreamHelloMethod;
  }

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static HelloStub newStub(io.grpc.Channel channel) {
    return new HelloStub(channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static HelloBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    return new HelloBlockingStub(channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static HelloFutureStub newFutureStub(
      io.grpc.Channel channel) {
    return new HelloFutureStub(channel);
  }

  /**
   */
  public static abstract class HelloImplBase implements io.grpc.BindableService {

    /**
     * <pre>
     *一元 RPC 模式
     * </pre>
     */
    public void sayHello(HelloRequest request,
                         io.grpc.stub.StreamObserver<HelloResponse> responseObserver) {
      asyncUnimplementedUnaryCall(getSayHelloMethod(), responseObserver);
    }

    /**
     * <pre>
     *服务器端流式RPC模式
     * </pre>
     */
    public void serviceStreamHello(HelloRequest request,
                                   io.grpc.stub.StreamObserver<HelloResponse> responseObserver) {
      asyncUnimplementedUnaryCall(getServiceStreamHelloMethod(), responseObserver);
    }

    /**
     * <pre>
     *客户端流式RPC模式
     * </pre>
     */
    public io.grpc.stub.StreamObserver<HelloRequest> clientStreamHello(
        io.grpc.stub.StreamObserver<HelloResponseList> responseObserver) {
      return asyncUnimplementedStreamingCall(getClientStreamHelloMethod(), responseObserver);
    }

    /**
     * <pre>
     *双向流式RPC模式
     * </pre>
     */
    public io.grpc.stub.StreamObserver<HelloRequest> clientServiceStreamHello(
        io.grpc.stub.StreamObserver<HelloResponse> responseObserver) {
      return asyncUnimplementedStreamingCall(getClientServiceStreamHelloMethod(), responseObserver);
    }

    @Override public final io.grpc.ServerServiceDefinition bindService() {
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
          .addMethod(
            getSayHelloMethod(),
            asyncUnaryCall(
              new MethodHandlers<
                HelloRequest,
                HelloResponse>(
                  this, METHODID_SAY_HELLO)))
          .addMethod(
            getServiceStreamHelloMethod(),
            asyncServerStreamingCall(
              new MethodHandlers<
                HelloRequest,
                HelloResponse>(
                  this, METHODID_SERVICE_STREAM_HELLO)))
          .addMethod(
            getClientStreamHelloMethod(),
            asyncClientStreamingCall(
              new MethodHandlers<
                HelloRequest,
                HelloResponseList>(
                  this, METHODID_CLIENT_STREAM_HELLO)))
          .addMethod(
            getClientServiceStreamHelloMethod(),
            asyncBidiStreamingCall(
              new MethodHandlers<
                HelloRequest,
                HelloResponse>(
                  this, METHODID_CLIENT_SERVICE_STREAM_HELLO)))
          .build();
    }
  }

  /**
   */
  public static final class HelloStub extends io.grpc.stub.AbstractStub<HelloStub> {
    private HelloStub(io.grpc.Channel channel) {
      super(channel);
    }

    private HelloStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected HelloStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new HelloStub(channel, callOptions);
    }

    /**
     * <pre>
     *一元 RPC 模式
     * </pre>
     */
    public void sayHello(HelloRequest request,
                         io.grpc.stub.StreamObserver<HelloResponse> responseObserver) {
      asyncUnaryCall(
          getChannel().newCall(getSayHelloMethod(), getCallOptions()), request, responseObserver);
    }

    /**
     * <pre>
     *服务器端流式RPC模式
     * </pre>
     */
    public void serviceStreamHello(HelloRequest request,
                                   io.grpc.stub.StreamObserver<HelloResponse> responseObserver) {
      asyncServerStreamingCall(
          getChannel().newCall(getServiceStreamHelloMethod(), getCallOptions()), request, responseObserver);
    }

    /**
     * <pre>
     *客户端流式RPC模式
     * </pre>
     */
    public io.grpc.stub.StreamObserver<HelloRequest> clientStreamHello(
        io.grpc.stub.StreamObserver<HelloResponseList> responseObserver) {
      return asyncClientStreamingCall(
          getChannel().newCall(getClientStreamHelloMethod(), getCallOptions()), responseObserver);
    }

    /**
     * <pre>
     *双向流式RPC模式
     * </pre>
     */
    public io.grpc.stub.StreamObserver<HelloRequest> clientServiceStreamHello(
        io.grpc.stub.StreamObserver<HelloResponse> responseObserver) {
      return asyncBidiStreamingCall(
          getChannel().newCall(getClientServiceStreamHelloMethod(), getCallOptions()), responseObserver);
    }
  }

  /**
   */
  public static final class HelloBlockingStub extends io.grpc.stub.AbstractStub<HelloBlockingStub> {
    private HelloBlockingStub(io.grpc.Channel channel) {
      super(channel);
    }

    private HelloBlockingStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected HelloBlockingStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new HelloBlockingStub(channel, callOptions);
    }

    /**
     * <pre>
     *一元 RPC 模式
     * </pre>
     */
    public HelloResponse sayHello(HelloRequest request) {
      return blockingUnaryCall(
          getChannel(), getSayHelloMethod(), getCallOptions(), request);
    }

    /**
     * <pre>
     *服务器端流式RPC模式
     * </pre>
     */
    public java.util.Iterator<HelloResponse> serviceStreamHello(
        HelloRequest request) {
      return blockingServerStreamingCall(
          getChannel(), getServiceStreamHelloMethod(), getCallOptions(), request);
    }
  }

  /**
   */
  public static final class HelloFutureStub extends io.grpc.stub.AbstractStub<HelloFutureStub> {
    private HelloFutureStub(io.grpc.Channel channel) {
      super(channel);
    }

    private HelloFutureStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected HelloFutureStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new HelloFutureStub(channel, callOptions);
    }

    /**
     * <pre>
     *一元 RPC 模式
     * </pre>
     */
    public com.google.common.util.concurrent.ListenableFuture<HelloResponse> sayHello(
        HelloRequest request) {
      return futureUnaryCall(
          getChannel().newCall(getSayHelloMethod(), getCallOptions()), request);
    }
  }

  private static final int METHODID_SAY_HELLO = 0;
  private static final int METHODID_SERVICE_STREAM_HELLO = 1;
  private static final int METHODID_CLIENT_STREAM_HELLO = 2;
  private static final int METHODID_CLIENT_SERVICE_STREAM_HELLO = 3;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final HelloImplBase serviceImpl;
    private final int methodId;

    MethodHandlers(HelloImplBase serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @Override
    @SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_SAY_HELLO:
          serviceImpl.sayHello((HelloRequest) request,
              (io.grpc.stub.StreamObserver<HelloResponse>) responseObserver);
          break;
        case METHODID_SERVICE_STREAM_HELLO:
          serviceImpl.serviceStreamHello((HelloRequest) request,
              (io.grpc.stub.StreamObserver<HelloResponse>) responseObserver);
          break;
        default:
          throw new AssertionError();
      }
    }

    @Override
    @SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_CLIENT_STREAM_HELLO:
          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.clientStreamHello(
              (io.grpc.stub.StreamObserver<HelloResponseList>) responseObserver);
        case METHODID_CLIENT_SERVICE_STREAM_HELLO:
          return (io.grpc.stub.StreamObserver<Req>) serviceImpl.clientServiceStreamHello(
              (io.grpc.stub.StreamObserver<HelloResponse>) responseObserver);
        default:
          throw new AssertionError();
      }
    }
  }

  private static abstract class HelloBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
    HelloBaseDescriptorSupplier() {}

    @Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return HelloProto.getDescriptor();
    }

    @Override
    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
      return getFileDescriptor().findServiceByName("Hello");
    }
  }

  private static final class HelloFileDescriptorSupplier
      extends HelloBaseDescriptorSupplier {
    HelloFileDescriptorSupplier() {}
  }

  private static final class HelloMethodDescriptorSupplier
      extends HelloBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
    private final String methodName;

    HelloMethodDescriptorSupplier(String methodName) {
      this.methodName = methodName;
    }

    @Override
    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
      return getServiceDescriptor().findMethodByName(methodName);
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (HelloGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new HelloFileDescriptorSupplier())
              .addMethod(getSayHelloMethod())
              .addMethod(getServiceStreamHelloMethod())
              .addMethod(getClientStreamHelloMethod())
              .addMethod(getClientServiceStreamHelloMethod())
              .build();
        }
      }
    }
    return result;
  }
}
